// import './高级类型'
import './类型保护'
//  1. 接口
interface Person {
	name: string
	age: number
	code: number
	sex: string
	weight?: number
}

const p1: Person = {
	name: '张三',
	age: 19,
	code: 110,
	sex: '男',
	weight: 180
}


// 2. 泛型
interface MyArray<T> {
	[porpsName: number]: T
}

const arr: MyArray<string> = ['a', 'b', 'c']
const arr1: MyArray<boolean | number> = [true, false, 123]

// 3. 类
class Animal {
	name: string
	age: number
	constructor(name: string, age: number) {
		this.name = name
		this.age = age;
	}
}

new Animal('张三', 18)


// 4. 函数
function add(a: number, b: number): number {
	return a + b
}